//
//  Model.m
//  cookBook
//
//  Created by xalo on 16/1/23.
//  Copyright © 2016年 张广斌. All rights reserved.
//

#import "Model.h"
#import <UIKit/UIKit.h>

@implementation Model

-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}

//编码
-(void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:_age forKey:@"age"];
    [aCoder encodeObject:_category forKey:@"category"];
    [aCoder encodeObject:_effect forKey:@"effect"];
    [aCoder encodeObject:_ID forKey:@"ID"];
    [aCoder encodeObject:_thumb forKey:@"thumb"];
    [aCoder encodeDataObject:UIImagePNGRepresentation(_pictureImage)];
    [aCoder encodeObject:_title forKey:@"title"];
    [aCoder encodeObject:_yingyang forKey:@"yingyang"];
    [aCoder encodeObject:_jianjie forKey:@"jianjie"];
    [aCoder encodeObject:_yuanliao forKey:@"yuanliao"];
}


//解码
-(instancetype)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];
    if (self) {
        self.age = [aDecoder decodeObjectForKey:@"age"];
        self.category = [aDecoder decodeObjectForKey:@"category"];
        self.effect = [aDecoder decodeObjectForKey:@"effect"];
        self.ID = [aDecoder decodeObjectForKey:@"ID"];
        self.thumb = [aDecoder decodeObjectForKey:@"thumb"];
        self.pictureImage = [UIImage imageWithData:[aDecoder decodeDataObject]];
        self.title = [aDecoder decodeObjectForKey:@"title"];
        self.yingyang = [aDecoder decodeObjectForKey:@"yingyang"];
        self.jianjie = [aDecoder decodeObjectForKey:@"jianjie"];
        self.yuanliao = [aDecoder decodeObjectForKey:@"yuanliao"];

    }
    return self;
}

-(NSString *)description
{
    return [NSString stringWithFormat:@"%@,%@,%@,%@,%@,%@,%@,%@",self.age,self.category,self.effect,self.ID,self.thumb,self.title,self.yingyang,self.jianjie];
}
@end
